
/**
 * @author Steve Pennington and Julie Sparrow
 *
 */
public class TwoConnectTwo {
	
	private static Move[] moves = new Move[15];
	
	static {
		moves[0] = new Move();
		moves[0].column = 3;
		moves[0].piece = Board.BLUE;
		
		moves[1] = new Move();
		moves[1].column = 5;
		
		moves[2] = new Move();
		moves[2].column = 3;
		moves[2].piece = Board.BLUE;
		
		moves[3] = new Move();
		moves[3].column = 4;
		
		moves[4] = new Move();
		moves[4].column = 3;
		moves[4].piece = Board.BLUE;
		
		moves[5] = new Move();
		moves[5].column = 4;
		
		moves[6] = new Move();
		moves[6].column = 0;
		moves[6].piece = Board.GREEN;
		
		moves[7] = new Move();
		moves[7].column = 5;
		
		moves[8] = new Move();
		moves[8].column = 1;
		moves[8].piece = Board.BLUE;
		
		moves[9] = new Move();
		moves[9].column = 3;
		
		moves[10] = new Move();
		moves[10].column = 1;
		moves[10].piece = Board.GREEN;
		
		moves[11] = new Move();
		moves[11].column = 5;
		
		moves[12] = new Move();
		moves[12].column = 2;
		moves[12].piece = Board.BLUE;
		
		moves[13] = new Move();
		moves[13].column = 5;
		
		moves[14] = new Move();
		moves[14].column = 2;
		moves[14].piece = Board.BLUE;
	}

	/**
	 * Main entry point into the application
	 * @param args
	 * 		command line arguments
	 */
	public static void main(String[] args) {
		IO.init(System.in);
		GameState gameState = IO.parseGameState();
		Board board = IO.parseBoard(gameState.numCols, gameState.numRows);
		IO.close();
		Evaluator evaluator = new AI.ChainEvaluator();
		Move move;
		int pieces = board.getPieceCount();
		if(pieces % 2 == 0 && pieces <= 14) {
			if(pieces > 0 && gameState.lastCol != moves[pieces-1].column) {
				move = AI.minMax(board, 3, evaluator);
			} else {
				move = moves[pieces];
			}
		} else {
			move = AI.minMax(board, 3, evaluator);
		}
		System.out.println("(" + (move.column + 1)+ ", " + IO.pieceMap[move.piece] + ")");
	}
}
